package com.sram.service.impl;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;

import com.sram.dao.UserDao;
import com.sram.entity.User;
import com.sram.service.UserService;

public class UserServiceImpl implements UserService {
	private UserDao userDao;
	
	public UserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}

	@Override
	public void deleteUser(int id) {
		userDao.deleteUser(id);
	}

	@Override
	public User login(String userName, String password) {
		return userDao.getUserByUserNameAndPassword(userName, password);
	}

	@Override
	public void saveUser(User user) {
		userDao.addUser(user);
	}

	@Override
	public void updateUser(User user) {
		userDao.updateUser(user);
	}

	@Override
	public User usernameisUnique(String userName) {
		return userDao.getUserByUserName(userName);

	}
	@Override
	public List<User> findUser(DetachedCriteria detachedCriteria) {
		return userDao.findUser(detachedCriteria);

	}

	@Override
	public List<User> findall() {
		// TODO Auto-generated method stub
		return userDao.findall();
	}

	@Override
	public List<User> findByDetachedCriteriaLimit(DetachedCriteria detachedCriteria, int firstResult, int pageSize) {
		// TODO Auto-generated method stub
		return  userDao.pageQuery(detachedCriteria, firstResult, pageSize);
	}
}
